#ifndef __ROtateMatrix__
#define __ROtateMatrix__
#include <vector>
#include <iostream>

//将方阵顺时针旋转 90 度
/*
* 1 2  ----->  3 1
* 3 4  ----->  4 2
*/

//翻转代替旋转
//对角线 翻转 + 中垂线 翻转
void RotateMatrixOverturn(std::vector<std::vector<int>>& matrix) {
	int row = matrix.size();
	//对角线 翻转
	for (int i = 0; i < row; i++)
		for (int j = i + 1; j < row - i; j++)
			std::swap(matrix[i][j], matrix[j][i]);
	
	//中垂线 翻转
	for (int i = 0; i < row / 2; i ++)
		for (int j = 0; j < row; j++)
			std::swap(matrix[j][i], matrix[j][row - i - 1]);

	for (int i = 0; i < row; i++) {
		for (int j = 0; j < row; j++)
			std::cout << matrix[i][j] << " ";
		std::cout << std::endl;
	}
}


#endif // !__ROtateMatrix__
